package br.com.ordersys.web.client.modules.utils;

import com.google.gwt.core.client.impl.Md5Digest;

public class CryptUtils {
	public static String getMD5for(String text) {
		Md5Digest sd = new Md5Digest();
		byte[] bs = text.getBytes();
		return byteArrayToHexString(sd.digest(bs));
	}

	public static String byteArrayToHexString(final byte[] b) {
		final StringBuffer sb = new StringBuffer(b.length * 2);
		for (int i = 0, len = b.length; i < len; i++) {
			int v = b[i] & 0xff;
			if (v < 16)
				sb.append('0');
			sb.append(Integer.toHexString(v));
		}
		return sb.toString().toLowerCase();
	}
}
